#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int minOperations(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end(), [&](int a, int b) {
            return a > b;
            });
        if (nums.back() < k)
            return -1;
        nums.push_back(k);
        int res = 0;
        for (int i = 1; i < nums.size(); ++i)
        {
            if (nums[i] != nums[i - 1])
                ++res;
        }
        return res;
    }
};